package com.x.schedule.service.impl;

import com.x.schedule.DAO.SysUserDAO;
import com.x.schedule.DAO.impl.SysUserDAOImpl;
import com.x.schedule.pojo.SysUser;
import com.x.schedule.service.SysUserService;
import com.x.schedule.util.MD5Util;

/**
 * ClassName: SysUserServiceImpl
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.08.25 17:23
 */
public class SysUserServiceImpl implements SysUserService {

    private SysUserDAO userDAO = new SysUserDAOImpl();
    @Override
    public int regist(SysUser sysUser) {
        //密码加密
        String username = sysUser.getUsername();
        String userPwd = sysUser.getUserPwd();
        String encryptedPwd = MD5Util.encrypt(userPwd);
        sysUser.setUserPwd(encryptedPwd);

        //调用DAO层方法，将信息存入数据库
        int rows = userDAO.addSysUser(sysUser);
        return rows;
    }

    @Override
    public SysUser findUserName(String username) {
        return userDAO.findByUserName(username);
    }
}
